home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
FROMUTS
/
UNIXLIB37B
/
test
/
c
/
memtest
< prev
next >
Wrap
Text File
|
1991-06-10
|
621b
|
36 lines
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <stdio.h>
static char *s,*d;
static void memtest(void)
{
register clock_t t;
register int i;
t = clock();
for (i = 0; i < 2048; i++)
memcpy(d + (rand() & 3),s + (rand() & 3),rand() & 2047);
t = clock() - t;
printf("%d.%02d\n",t / CLK_TCK,t % CLK_TCK);
}
int main(int argc,char **argv)
{
int i,n;
if (argc != 2) { puts("usage: memtest ntest"); exit(1); }
n = atoi(argv[1]);
if (!(s = malloc(2048))) { perror("malloc()"); exit(1); }
if (!(d = malloc(2048))) { perror("malloc()"); exit(1); }
srand(time(0));
for (i = 0; i < n; i++) memtest();
}